<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@taglib uri="/authtaglib" prefix="auth" %>
<!DOCTYPE html>
<html>
<head>
<title>人员管理</title>
<jsp:include page="/include.jsp"/>
<script type="text/javascript">


//删除
function doDeleteDatasource(ids) {
    window.top.$.messager.confirm('提示', '是否确定删除该条记录？', function (b) {
        if (b) {
            $.ajax({
                url: '${pageContext.request.contextPath}/cnbdw/employeeRoomHistoryAction!delete.action',
                dataType: 'json',
                data: {ids: ids},
                success: function (data) {
                    $.messager.show({title: '提示', msg: data.returnMsg});
                    if (data.returnFlag) {
                        //刷新主列表
                        $('#datagrid').datagrid('reload');
                    }
                }
            });

        }
    });
}

//批量删除
function doBatchDelete() {
    var rows = $('#datagrid').datagrid('getChecked')
    if (rows.length <= 0) {
        $.messager.alert('提示', '没有选择任何记录');
    } else {
        var itemIds = [];
        $.each(rows, function (i, item) {
            itemIds.push(item.id);
        });
        $.messager.confirm('删除确认', '是否确定删除选中记录？', function (r) {
            if (r) {
                $.ajax({
                    url: '${pageContext.request.contextPath}/cnbdw/employeeRoomHistoryAction!delete.action',
                    async: false,
                    data: {ids: itemIds.join(",")},
                    dataType: "json",
                    success: function (result) {
                        $.messager.show({title: '提示', msg: result.returnMsg});
                        if (result.returnFlag) {
                            //刷新主列表
                            $('#datagrid').datagrid('reload');
                        }
                    }
                });
            }
        });
    }
}

//执行查询
function doQuery() {
    if ($("#datasource_query_form").form("validate")) {
        $("#datagrid").datagrid('options').queryParams = serializeObject($('#datasource_query_form')); //把查询条件赋值给datagrid内部变量
        $("#datagrid").datagrid('load'); //重新加载
    }
}
//重置查询条件
function doReset() {
    $('#datasource_query_form').form('reset');
     if ($("#datasource_query_form").form("validate")) {
        $("#datagrid").datagrid('options').queryParams = serializeObject($('#datasource_query_form')); //把查询条件赋值给datagrid内部变量
        $("#datagrid").datagrid('load'); //重新加载
    }
}
//页面加载完后响应 onReady
$(function () {
    //查询按纽绑定事件
    $('#btnQuery').bind('click', doQuery);
    //重置按纽绑定事件
    $('#btnReset').bind('click', doReset);
    //初始化主列表
    $('#datagrid').datagrid({
        url: '${pageContext.request.contextPath}/cnbdw/employeeRoomHistoryAction!getAllDatasourceList.action',
        fit: true,
        border: false,
        fitColumns: true,
        pagination: true,
        pageList: [30],
        rownumbers: false,
        sortName: 'id',
        sortOrder: 'desc',
        striped: true,
        columns: [
            [
              
                {field: 'empId', title: '姓名', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'roomId', title: '当前房号', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                 {field: 'bedNo', title: '当前床号', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'origRoomId', title: '前房号', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
               
                {field: 'origBedNo', title: '前床号', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                
                {field: 'type', title: '房类型', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
               
                {field: 'deck', title: '甲板', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'area', title: '区域', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'operateType', title: '操作类型', align: 'left', formatter: function (value, rowData, rowIndex) 
                {
                if(value == 1){
                return "退房"
                }else if(value == 2){
                return "换房"
                }else{
                 return "入住"
                }
               
                }
                },
                {field: 'updateUser', title: '操作人', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'createTime', title: '操作时间', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'createUser', title: '更新人', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'updateTime', title: '更新时间', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'reason', title: '原因', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'action', title: '人员操作', align: 'right',
                    formatter: function (value, row, index) {
                        var html = "";
                       
                        <auth:button authUrl="cnbdw/employeeRoomHistoryAction!delete.action">
                        html += '<span style="cursor:pointer" onclick="doDeleteDatasource(\'' + row.id + '\')"><img src="${pageContext.request.contextPath}/images/icons/delete.png" title="删除" alt="删除" style="margin-top:2px;">删除&nbsp;&nbsp;</span>';
                        </auth:button>
                        return html;
                    }
                }
            ]
        ],
        toolbar: '#datagrid_toobar'
    });
});


</script>
</head>
<body class="easyui-layout">
<form id="datasource_query_form" method="post">
    <div data-options="region:'north'" style="height:60px;border-bottom:none;border-top:none;">
        <table border="0" cellpadding="0" cellspacing="0" height="100%" width="50%">
            <tr>
                <td style="width:1%;text-align:left;" nowrap="nowrap">
                    <label for="datasource_datsourcename">姓名：</label>
                </td>
                <td style="width:1%;text-align:left;" nowrap="nowrap">
                    <input type="text" id="datasource_datsourcename" name="name" class="easyui-validatebox"
                           data-options="validType:'specialCharFilter'"/>
                </td>
                <td style="width:1%;text-align:left;" nowrap="nowrap">
                    <label for="datasource_datsourcename">房间：</label>
                </td>
                <td style="width:15%;text-align:left;" nowrap="nowrap">
                    <input type="text" id="datasource_datsourcename" name="roomNo" class="easyui-validatebox"
                           data-options="validType:'specialCharFilter'"/>
                </td>
                
                <td style="width:1%;text-align:left;" nowrap="nowrap"
						class="tr_left"><label>开始时间：</label> <input id="start"
						name="start" type="text" class="easyui-datebox">&emsp;</td>
					<td style="width:1%;text-align:left;" nowrap="nowrap"
						class="tr_left"><label>结束时间：</label> <input id="end"
						name="end" type="text" class="easyui-datebox">&emsp;</td>
                
                <td colspan="2" style="width:10%;text-align:left;" nowrap="nowrap">
                    <input type="button" id="btnQuery" value="查 询" class="search_btn"/>
                    <input type="button" id="btnReset" value="重 置" class="reset_btn"/>
                </td>
            </tr>
        </table>
    </div>
     <div data-options="region:'center'" style="border-top:none">
        <table id="datagrid"></table>
        
    </div>
</form>
</body>
</html>

